#!/bin/sh

# Updates MODULE inside go.mod if it is already present to version VERSION.

set -e

if grep -q "$MODULE " go.mod; then
  # If MODULE is "go.opentelemetry.io/collector" need to update "go.opentelemetry.io/collector/model" as well.
  go get "$MODULE"@"$VERSION"
  if [ "$MODULE" == "go.opentelemetry.io/collector" ]; then
    MODEL=$MODULE"/model"
    go get "$MODEL"@"$VERSION"
  fi
fi
